package modelimplementation

import "time"

/*
 * 月底支付
 */

type MonthlySchedule struct {
}

func (ms *MonthlySchedule) IsLastDayOfMonth(date time.Time) bool {
	month1 := date.Month()
	month2 := date.AddDate(0, 0, 1).Month()
	return month1 != month2
}

func (ms *MonthlySchedule) IsPayData(date time.Time) bool {
	return ms.IsLastDayOfMonth(date)
}

func (ms *MonthlySchedule) GetPayPeriodStartDate(payPeriodEndDate time.Time) time.Time {
	lastDayOfMonth := payPeriodEndDate.Day()
	firstDayOfMonth := payPeriodEndDate.AddDate(0, 0, -(lastDayOfMonth - 1))
	return firstDayOfMonth
}

